﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OpenSoftStore.BusinessLogic.Member;
using OpenSoftStore.Orm.Model;

namespace OpenSoftStore.Client.UIL.ManageMember.Info
{
    public partial class MemberPassEditWindow : Form
    {
        public T_Member Member;
        public MemberLogic LgcMember;

        public MemberPassEditWindow()
        {
            InitializeComponent();
            Member=new T_Member();
            LgcMember=new MemberLogic();

            txtOldPass.Focus();
        }

        public void GetMember(T_Member member)
        {
            Member = member;
        }

        private void BtnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void pbClose_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (txtNewPass.Text != txtSurePass.Text)
            {
                FormSysMessage.ShowMessage("新密码输入不一致!");
                return;
            }
            if(Member.Pass !=txtOldPass.Text)
            {
                FormSysMessage.ShowMessage("旧密码不正确!");
                return;
            }
            Member.Pass = txtNewPass.Text;
            Boolean result= LgcMember.UpdatePass(Member);
            if (result == false) FormSysMessage.ShowMessage("操作失败！");
            else Close();
        }
    }
}
